<template>
  <div class="adminSet">
    <el-form :model="ruleForm" :rules="rules" ref="ruleForm" label-width="200px" class="demo-ruleForm">
      <el-row>
        <el-tabs v-model="attrType" type="border-card">
          <el-tab-pane label="基础信息" name="first">
            <el-row>
              <el-form-item label="商品类型" prop="goodsStyle">
                <el-select v-model="ruleForm.goodsStyle" class="input_edit" placeholder="请选择" clearable disabled>
                  <el-option label="普通商品" :value="1"></el-option>
                  <el-option label="宴席商品" :value="2"></el-option>
                  <el-option label="生日专属商品" :value="3"></el-option>
                  <el-option label="预售商品" :value="4"></el-option>
                </el-select>
              </el-form-item>
              <el-form-item label="是否订单唯一" prop="isOnly" v-if="ruleForm.goodsStyle == '2'">
                <el-radio v-model="ruleForm.isOnly" label="1" disabled>是</el-radio>
                <el-radio v-model="ruleForm.isOnly" label="0" disabled>否</el-radio>
              </el-form-item>
              <el-form-item label="商品名称" prop="goodsName">
                <el-input v-model="ruleForm.goodsName" class="input_edit" readonly></el-input>
              </el-form-item>
              <el-form-item label="惊喜价" prop="activityPrice" v-if="ruleForm.goodsStyle == '3'">
                <el-input v-model="ruleForm.activityPrice" class="input_edit" style="text-align-last: right"
                  placeholder="惊喜价" readonly>
                  <template slot="append">元</template>
                </el-input>
              </el-form-item>

              <el-form-item label="惊喜价有效期" prop="dateRange" v-if="ruleForm.goodsStyle == '3'">
                <el-date-picker v-model="dateRange" type="datetimerange" range-separator="至" start-placeholder="开始时间"
                  end-placeholder="结束时间" value-format="yyyy-MM-dd HH:mm:ss" readonly></el-date-picker>
              </el-form-item>
              <!-- <el-form-item label="国际条码" prop="barCode">
                <el-input
                  v-model="ruleForm.barCode"
                  class="input_edit"
                  readonly
                ></el-input>
              </el-form-item> -->
              <el-form-item label="国际条码" prop="barCode">
                <el-input v-model="ruleForm.barCode" class="input_edit" :maxlength="30" readonly>
                </el-input>
              </el-form-item>

              <el-form-item label="首页推荐" prop="recommend">
                <el-radio-group v-model="ruleForm.recommend" disabled>
                  <el-radio :label="0">不推荐</el-radio>
                  <el-radio :label="1">推荐</el-radio>
                </el-radio-group>
              </el-form-item>
              <!-- <div class="form-item-inline"></div> -->

              <el-form-item label="建议零售价" prop="salePrice">
                <el-input v-model="ruleForm.salePrice" :maxlength="10" class="input_edit" style="text-align-last: right"
                  placeholder="零售价" readonly>
                  <template slot="append">元</template>
                </el-input>
              </el-form-item>

              <el-form-item label="商品限价" prop="saleLowerPrice">
                <el-input v-model="ruleForm.saleLowerPrice" :maxlength="10" class="input_edit"
                  style="text-align-last: right" placeholder="限价" readonly>
                  <template slot="append">元</template>
                </el-input>
              </el-form-item>

              <el-form-item label="会员价" prop="memberPrice">
                <el-input v-model="ruleForm.memberPrice" :maxlength="10" class="input_edit"
                  style="text-align-last: right" placeholder="会员价" readonly>
                  <template slot="append">元</template>
                </el-input>
              </el-form-item>
              <!-- <div class="form-item-inline"></div> -->

              <el-form-item label="商品分类" prop="goodsTypeId">
                <el-select v-model="ruleForm.goodsTypeId" class="input_edit" disabled>
                  <el-option v-for="(send, i) in typeData" :key="i" :value="send.goodsTypeId"
                    :label="send.goodsTypeName">
                  </el-option>
                </el-select>
              </el-form-item>

              <el-form-item label="消费者酒币" prop="consumerIntegral">
                <el-input v-model="ruleForm.consumerIntegral" class="input_edit" :maxlength="30" readonly>
                </el-input>
              </el-form-item>

              <el-form-item label="商家云币" prop="merchantIntegral">
                <el-input v-model="ruleForm.merchantIntegral" class="input_edit" :maxlength="30" readonly>
                </el-input>
              </el-form-item>
              <!-- <div class="form-item-inline"></div> -->
              <el-form-item label="商品单位" prop="unitName">
                <el-input v-model="ruleForm.unitName" class="input_edit" readonly></el-input>
              </el-form-item>
              <el-form-item label="商品标签" prop="labellist">
                <el-input v-model="ruleForm.labellist" type="textarea" placeholder="请输入商品标签，用英文逗号隔开多个标签"
                  style="width: 600px;" :autosize="{ minRows: 4 }" readonly></el-input>
              </el-form-item>
              <el-form-item label="展示顺序" prop="sortNo">
                <el-input v-model="ruleForm.sortNo" class="input_edit" readonly
                  style="text-align-last: right"></el-input>
              </el-form-item>
              <el-form-item label="最小购买数" class="item" prop="minBuyCount" v-if="ruleForm.goodsStyle == 2">
                <el-input v-model.number="ruleForm.minBuyCount" :maxlength="4" :min="1" type="number"
                  oninput="value=value.replace(/[^0-9]/g,'')" class="input_edit" style="text-align-last: right"
                  placeholder="最小购买数" v-on:blur="check(ruleForm.minBuyCount)">
                  <template v-if="ruleForm.unit == 'u01p-50'" slot="append">箱</template>
                  <template v-if="ruleForm.unit == 'u01p-06'" slot="append">瓶</template>
                  <template v-if="ruleForm.unit == 'u01p-07'" slot="append">套</template>
                </el-input>
              </el-form-item>
              <!-- <el-form-item label="标签类型" prop>
                <div style="margin-top: 0px">
                  <el-checkbox-group v-model="ruleForm.tagType">
                    <el-checkbox-button v-for="item in tagTypeform.tagTypeCodes" :key="item.id" :label="item.id">{{
                      item.label
                    }}</el-checkbox-button>
                  </el-checkbox-group>
                </div>
              </el-form-item> -->
              <!-- <el-form-item label="是否最小单位" prop>
                <el-radio v-model="ruleForm.isMinUnit" label="1" disabled>是</el-radio>
                <el-radio v-model="ruleForm.isMinUnit" label="0" disabled>否</el-radio>
              </el-form-item> -->
              <el-form-item label="最小单位商品" prop="minUnitGoodsId" v-if="ruleForm.isMinUnit != '1'">
                <el-select class="input_edit" filterable v-model="ruleForm.minUnitGoodsId" clearable disabled :rules="[
                  {
                    required: true,
                    message: '最小单位商品不能为空',
                    trigger: 'blur',
                  },
                ]">
                  <el-option v-for="send in minUnitGoodsIdData" :key="send.goodsId" :value="send.goodsId"
                    :label="send.goodsName + '(单位：' + send.unitName + ')'"></el-option>
                </el-select>
              </el-form-item>
              <el-form-item label="单位转换比例" prop="unitConvertRate" v-if="ruleForm.isMinUnit != '1'">
                <el-input v-model="ruleForm.unitConvertRate" class="input_edit" placeholder="请输入正整数" readonly
                  style="text-align-last: right"></el-input>
              </el-form-item>
              <el-form-item label="是否为限购商品" prop="isBuyLimit">
                <el-radio v-model="ruleForm.goodsLimitConfig.isBuyLimit" label="1" disabled>是</el-radio>
                <el-radio v-model="ruleForm.goodsLimitConfig.isBuyLimit" label="0" disabled>否</el-radio>
              </el-form-item>
              <div v-if="ruleForm.goodsLimitConfig.isBuyLimit != 0">
                <!-- <el-row :span="12">
                            <el-col :span="10">
                                <el-form-item label="商品时效性" prop="dateRange">
                                    <el-date-picker
                                        v-model="dateRange"
                                        type="datetimerange"
                                        range-separator="至"
                                        start-placeholder="开始时间"
                                        end-placeholder="结束时间"
                                        value-format="yyyy-MM-dd HH:mm:ss"
                                        :picker-options="pickerOptions"
                                    ></el-date-picker>
                                </el-form-item>
                            </el-col>
                            <el-col :span="2">
                                <el-form-item>
                                    <el-checkbox v-model="checked1" style="border-radius: 50%;">不限时间</el-checkbox>
                                </el-form-item>
                            </el-col>
                                </el-row>-->
                <el-row :span="12">
                  <el-col :span="10">
                    <el-form-item v-if="ruleForm.unit == 'u01p-06'" label="每个用户只能购买(瓶)" prop="limitCount">
                      <el-input v-model="ruleForm.goodsLimitConfig.limitCount" type="number" :min="1" class="input_edit"
                        style="text-align-last: right" readonly></el-input>
                      <p class="tips">
                        *单个用户只能购买此商品设定限制瓶数
                      </p>
                    </el-form-item>
                    <el-form-item v-if="ruleForm.unit == 'u01p-50'" label="每个用户只能购买(箱)" prop="limitCount">
                      <el-input v-model="ruleForm.goodsLimitConfig.limitCount" type="number" :min="1" class="input_edit"
                        style="text-align-last: right" readonly></el-input>
                      <p class="tips">
                        *单个用户只能购买此商品设定限制箱数
                      </p>
                    </el-form-item>
                    <el-form-item v-if="ruleForm.unit == 'u01p-07'" label="每个用户只能购买(套)" prop="limitCount">
                      <el-input v-model="ruleForm.goodsLimitConfig.limitCount" type="number" :min="ruleForm.minBuyCount"
                        class="input_edit" style="text-align-last: right"
                        onkeypress="return (/[\d]/.test(String.fromCharCode(event.keyCode)))" placeholder="请输入正整数"
                        clearable :disabled="checked2" @onchange="
                          dayCountCheck(ruleForm.goodsLimitConfig.limitCount)
                          "></el-input>
                      <p class="tips">
                        *单个用户只能购买此商品设定限制套数
                      </p>
                    </el-form-item>
                  </el-col>
                  <el-col :span="2">
                    <el-form-item label prop="isSingleBuyLimit">
                      <el-checkbox v-model="checked2" style="border-radius: 50%" disabled>不限量</el-checkbox>
                    </el-form-item>
                  </el-col>
                </el-row>
                <el-row :span="12">
                  <el-col :span="10">
                    <el-form-item label="大区上架数量限制" prop="shelfLimitCount">
                      <el-input v-model="ruleForm.goodsLimitConfig.shelfLimitCount" type="number" class="input_edit"
                        style="text-align-last: right" readonly></el-input>
                      <p class="tips">
                        *设置上架数量后，商家端不能修改库存量
                      </p>
                    </el-form-item>
                  </el-col>
                  <el-col :span="2">
                    <el-form-item label prop="isWarzoneShelfLimit">
                      <el-checkbox v-model="checked3" style="border-radius: 50%" disabled>不限量</el-checkbox>
                    </el-form-item>
                  </el-col>
                </el-row>
              </div>
            </el-row>
          </el-tab-pane>

          <el-tab-pane label="详细信息" name="second">
            <el-row>
              <el-form-item label prop>
                <span style="
                                        margin-left: 0%;
                                        margin-top: 22%;
                                        margin-bottom: 20px;
                                        font-size: 20px;
                                        color: #000000;
                                    "></span>
              </el-form-item>
              <el-form-item label="商品主图" prop>
                <el-row>
                  <el-col style="margin: 10px; 0px; 10px; 0">
                    <el-upload v-if="fileList6.length > 0" style="margin: 10px" action :limit="1"
                      list-type="picture-card" :on-preview="handlePreview" :file-list="fileList6" :headers="headers">
                      <i class="el-icon-plus"></i>
                    </el-upload>
                    <p class="tips">
                      注：上传图片(限30M) 图片将用于消费者端商品列标图
                    </p>
                    <img width="100px" height="100px" v-if="fileList6.length == 0"
                      src="../../assets/images/public/nullPic.png" />
                  </el-col>
                </el-row>
              </el-form-item>
              <el-form-item label="商品详情" prop>
                <el-row>
                  <el-col style="margin: 10px; 0px; 10px; 0">
                    <el-upload v-if="fileList3.length > 0" style="margin: 10px" action :limit="1"
                      list-type="picture-card" :on-preview="handlePreview" :file-list="fileList3" :headers="headers">
                      <i class="el-icon-plus"></i>
                    </el-upload>
                    <p class="tips">
                      注：上传图片(限30M) 图片将用于消费者端产品详情图页
                    </p>
                    <img width="100px" height="100px" v-if="fileList3.length == 0"
                      src="../../assets/images/public/nullPic.png" />
                  </el-col>
                </el-row>
              </el-form-item>
              <el-form-item label="商品展示图" prop>
                <!-- <div class="demo-image__lazy">
                <el-image v-for="url in fileList2" :key="url" :src="url" lazy></el-image>
                                </div>-->
                <el-row>
                  <el-col style="margin: 10px; 0px; 10px; 0">
                    <el-upload v-if="fileList2.length > 0" style="margin: 10px" action :on-preview="handlePreview"
                      :file-list="fileList2" list-type="picture-card" :headers="headers">
                      <i class="el-icon-plus"></i>
                    </el-upload>
                    <p class="tips">
                      注：上传图片(限30M) 图片将用于消费者端产品详情图页轮播图
                    </p>
                    <img width="100px" height="100px" v-if="fileList2.length == 0"
                      src="../../assets/images/public/nullPic.png" />
                  </el-col>
                </el-row>
              </el-form-item>
            </el-row>
          </el-tab-pane>

          <el-tab-pane label="扩展信息" name="third">
            <vue-ueditor-wrap v-model="ruleForm.goodsDescribe" :config="myConfig" :destroy="true"></vue-ueditor-wrap>
          </el-tab-pane>
        </el-tabs>

        <el-row>
          <el-col :span="24" style="text-align: center; margin-top: 30px">
            <el-button type="primary" size="mini" @click="goback()">返回</el-button>
          </el-col>
        </el-row>
        <el-dialog :visible.sync="dialogVisibleImg" size="tiny">
          <img width="100%" :src="dialogImageUrl" alt />
        </el-dialog>
      </el-row>
    </el-form>
  </div>
</template>
<script>
import VueUeditorWrap from 'vue-ueditor-wrap';
import {
  queryStockGoods,
  queryGoodsCategorys,
  getProductUnitList,
  getGoodsInfoList,
  //   getSupplyList,
  queryGoodsBrands,
  createGoodsInfo,
  modifyGoodsInfo,
  deleteGoodsInfo,
  queryGoodsInfoAll,
  addGoodsGroup,
  getGoodsGroupList,
  batchaRenewGoodsParam,
  getGoodsParamsList,
} from '@/api/compositegoods';
import { queryGoodsTypeList } from '@/api/tagmanage';
import qs from 'qs';
export default {
  components: {
    VueUeditorWrap,
  },
  data() {
    return {
      listQuery: {
        current: 1,
        size: 10,
      },
      formInline: {
        goodsName: '',
      },
      headers: {
        token: localStorage.getItem('token'), //从cookie里获取token，并赋值  Authorization ，而不是token
      },
      attrType: 'first',
      active: 0,
      dialogVisibleFeatures: false,
      dialogVisibleFeaturesParam: false,
      dialogVisible: false,
      tableData: [],
      total: 0,
      strData: [],
      typeData: [],
      groupData: [],
      brandData: [],
      minUnitGoodsIdData: [],
      unitData: [],
      supplyData: [],
      selectData: [],
      featuresForm: {
        groupId: '',
        groupName: '',
      },
      featuresParamForm: {
        groupId: '',
        parameterName: '',
        parameterId: '',
        valueId: '',
      },
      featuresParamList: [
        {
          groupId: '',
          parameterName: '',
          parameterId: '',
          valueId: '',
        },
      ],
      featuresParamData: [],
      ruleForm: {
        goodsId: '',
        goodsAmount: '',
        goodsName: '',
        goodsStyle: '',
        isOnly: '0',
        minBuyCount: 1,
        barCode: '',
        sysCode: '',
        goodsTypeName: '',
        unitName: '',
        sortNo: '',
        buyPrice: '',
        activityPrice: '',
        saleLowerPrice: '',
        salePrice: '',
        saleUpperPrice: '',
        retailPrice: '',
        goodsDescribe: '',
        brandReq: '',
        minUnitGoodsId: '',
        status: '1',
        tagType: [],
        isGift: '0',
        upLower: '1',
        unit: '',
        isMinUnit: '1',
        minUniT: '',
        unitConvertRate: '',
        picture: '',
        pictures: '',
        groupList: [],
        paramValueList: [],
        parameters: [],
        groupId: '',
        groupName: '',
        goodsLimitConfig: {
          isBuyLimit: '0', //是否限购商品(1-是0-否)
          isTimeLimit: '0', //是否时效性商品(1-是0-否)
          limitCreateTime: '', //开始时间
          limitEndTime: '', //结束时间
          isSingleBuyLimit: '0', //每个用户购买是否限量(1-是0-否)
          limitCount: '', //用户购买限制数
          isWarzoneShelfLimit: '0', //大区上架数量是否限量(1-是0-否)
          shelfLimitCount: '', //大区上架限制数
        },
        recommend: '',
        memberPrice: '',
        consumerIntegral: '',
        merchantIntegral: '',
        labellist: ''
      },
      dialogVisibleImg: false,
      dialogImageUrl: '',
      fileList2: [],
      fileList3: [],
      fileList6: [],
      tagTypeform: {
        tagTypeCodes: [],
      },
      myConfig: {
        // 编辑器不自动被内容撑高
        autoHeightEnabled: false,
        // 初始容器高度
        initialFrameHeight: 240,
        // 初始容器宽度
        initialFrameWidth: '100%',
        // 上传文件接口（这个地址是我为了方便各位体验文件上传功能搭建的临时接口，请勿在生产环境使用！！！）
        //   serverUrl: 'http://35.201.165.105:8000/controller.php',
        serverUrl: `${process.env.VUE_APP_BASE_API}/api/file-service/v1/file/uploadFile`,
        // UEditor 资源文件的存放路径，如果你使用的是 vue-cli 生成的项目，通常不需要设置该选项，vue-ueditor-wrap 会自动处理常见的情况，如果需要特殊配置，参考下方的常见问题2
        UEDITOR_HOME_URL: '../../ui/static/UEditor/',
        // UEDITOR_HOME_URL: "../../static/UEditor/"
      },
      rules: {},
    };
  },

  props: {
    value: {
      type: [String, Number],
      default: '',
    },
  },
  computed: {
    goodsId: {
      get() {
        return this.value || '';
      },
      set(value) {
        this.$emit('input', value);
      },
    },
  },

  activated() {
    // this.getGoodsGroupList();
  },

  mounted() {
    this.logininfo = localStorage.getItem('logininfo');
    this.orgSeq = JSON.parse(this.logininfo).orgSeq;
    this.getMinUnitGoodsId();
    this.queryGoodsTypeList();
    //this.getGoodsGroupList();
    let v = this.$route.params.edit;
    console.log('~🚀🚀🚀🚀~🚀🚀🚀🚀~🚀🚀🚀🚀~ ~ v:', v);
    if (v != undefined && v != null) {
      this.queryGoodsInfoAll(v);
    }
  },
  watch: {},
  methods: {
    goback() {
      this.$router.go('-1');
    },
    //过滤最小商品
    userFilter(query = '') {
      this.minUnitGoodsIdData.filter((item) => {
        if (item.goodsName.includes(query) || item.goodsId.includes(query)) {
          this.ruleForm.minUnitGoodsId = item.goodsId;
        }
      });
    },
    getUserWhiteList() {
      let data = {
        size: 100,
        current: 1,
        condition: {
          isMinUnit: '1',
        },
        ascs: [],
        descs: [],
      };
      getGoodsInfoList(data).then((res) => {
        this.minUnitGoodsIdData = res.records;
        this.userFilter();
      });
    },

    //查询最小单位商品
    getMinUnitGoodsId(v) {
      let data = {
        size: 100,
        current: 1,
        condition: {
          isMinUnit: '1',
          status: '1',
        },
        ascs: [],
        descs: [],
      };
      getGoodsInfoList(data).then((res) => {
        this.minUnitGoodsIdData = res.records;
      });
    },

    //查询商品供应商
    // getSupply(v) {
    //   let data = {};
    //   getSupplyList(data).then(res => {
    //     this.supplyData = res.records;
    //   });
    // },

    //预览图片
    handlePreview(file) {
      this.dialogImageUrl = file.url;
      this.dialogVisibleImg = true;
    },
    //打开挑选
    selectGoods() {
      this.dialogVisible = true;
      this.queryStockGoods();
    },
    //搜索查询
    search() {
      let data = {
        size: this.listQuery.size,
        current: this.listQuery.current,
        condition: {
          goodsName: this.formInline.goodsName,
          keyWord: this.formInline.goodsName,
          isComb: '0',
          orgSeq: this.orgseq,
        },
        ascs: [],
        descs: [],
      };
      queryStockGoods(data).then((res) => {
        this.tableData = res.records;
        this.total = res.total;
      });
    },
    //初始化查询商品列表
    queryStockGoods() {
      let data = {
        size: this.listQuery.size,
        current: this.listQuery.current,
        condition: {
          goodsName: '',
          keyWord: '',
          isComb: '0',
          orgSeq: this.orgSeq,
        },
        ascs: [],
        descs: [],
      };
      queryStockGoods(data).then((res) => {
        this.tableData = res.records;
        this.total = res.total;
      });
    },
    //初始化查询商品详情
    queryGoodsInfoAll(v) {
      //console.log(JSON.stringify(v),"rrrrrrrrrrrrrrrrr");
      let data = { goodsId: v.goodsId };
      queryGoodsInfoAll(data).then((res) => {
        //console.log(res,"yyyyyyyyyyyyyyyyyyyy");
        this.ruleForm.goodsId = res.result.goodsId;
        this.ruleForm.goodsName = res.result.goodsName;
        this.ruleForm.goodsStyle = v.goodsStyle;
        this.ruleForm.isOnly = String(v.isOnly);
        this.ruleForm.minBuyCount = v.minBuyCount;
        this.ruleForm.barCode = v.barCode;
        this.ruleForm.brandReq = v.brandReq;
        this.ruleForm.minUnitGoodsId = String(
          res.result.minUnitGoodsId == null ? '' : res.result.minUnitGoodsId
        );
        this.ruleForm.unitConvertRate = res.result.unitConvertRate;
        this.ruleForm.sysCode = v.sysCode;
        this.ruleForm.sortNo = res.result.sortNo;
        this.ruleForm.goodsTypeName = res.result.goodsTypeName;
        this.ruleForm.unitName = v.unitName;
        this.ruleForm.status = String(res.result.status);
        this.ruleForm.tagType = res.result.tagType && res.result.tagType.length > 0 ? res.result.tagType.split(',') : [];
        this.ruleForm.isGift = String(v.isGift);
        this.ruleForm.saleLowerPrice = v.saleLowerPrice;
        this.ruleForm.activityPrice = res.result.activityPrice;
        this.ruleForm.salePrice = v.salePrice;
        console.log('~🚀🚀🚀🚀~🚀🚀🚀🚀~🚀🚀🚀🚀~ ~ v.salePrice:', v.salePrice);
        // this.ruleForm.memberPrice = this.toPrice(res.result.memberPrice);
        // this.ruleForm.labellist = res.result.labellist;
        // this.ruleForm.recommend = res.result.recommend;
        // this.ruleForm.consumerIntegral = res.result.consumerIntegral;
        // this.ruleForm.merchantIntegral = res.result.merchantIntegral;
        this.ruleForm.saleUpperPrice = v.saleUpperPrice;
        this.ruleForm.upLower = String(res.result.upLower);
        this.ruleForm.unit = String(res.result.unit);
        this.ruleForm.isMinUnit = String(res.result.isMinUnit);
        this.ruleForm.minUniT = String(v.minUniT == null ? 'BT' : v.minUniT);
        this.ruleForm.goodsDescribe = res.result.goodsDescribe;
        this.ruleForm.picture =
          res.result.picture == null ? '' : res.result.picture;
        this.ruleForm.pictures =
          res.result.pictures == null ? [] : res.result.pictures;
        this.ruleForm.paramValueList =
          res.result.paramValueList == null
            ? this.ruleForm.paramValueList
            : res.result.paramValueList;

        if (this.ruleForm.goodsStyle == 1 || this.ruleForm.goodsStyle == 4) {
          this.ruleForm.recommend = res.result.recommend;
          this.ruleForm.memberPrice = res.result.memberPrice;
          this.ruleForm.consumerIntegral = res.result.consumerIntegral;
          this.ruleForm.merchantIntegral = res.result.merchantIntegral;
          this.ruleForm.labellist = res.result.labellist;
        }

        let img = res.result.img;
        if (img != null) {
          var picUrl = img.picUrl;
          var index = picUrl.lastIndexOf('.');
          var aa = picUrl.substring(index - 5, picUrl.length);
          var picId = img.picId;
          let data = {
            name: aa,
            url: picUrl,
          };
          this.fileList3.push(data);
        }

        let picture = this.ruleForm.picture;
        if (picture != null) {
          var picUrl = picture.picUrl;
          var index = picUrl.lastIndexOf('.');
          var aa = picUrl.substring(index - 5, picUrl.length);
          var picId = picture.picId;
          let data = {
            name: aa,
            url: picUrl,
          };
          this.fileList6.push(data);
        }

        let pictures = this.ruleForm.pictures; //v.pictures;
        if (pictures != null && pictures.length > 0) {
          pictures.forEach((item, i) => {
            var picUrl = item.picUrl;
            var index = picUrl.lastIndexOf('.');
            var aa = picUrl.substring(index - 5, picUrl.length);
            var name = item.name;
            let data = {
              name: aa,
              url: picUrl,
            };
            this.fileList2.push(data);
            // this.fileList2.push(picUrl);
          });
        }

        let goodsLimitConfig = res.result.goodsLimitConfig;
        if (goodsLimitConfig !== undefined && goodsLimitConfig != null) {
          let beginTime = goodsLimitConfig.limitCreateTime;
          let endTime = goodsLimitConfig.limitEndTime;
          if (beginTime != null && endTime != null) {
            this.dateRange = [beginTime, endTime];
          }
          this.checked1 = goodsLimitConfig.isTimeLimit == '1' ? true : false;
          this.checked2 =
            goodsLimitConfig.isSingleBuyLimit == '1' ? true : false;
          this.checked3 =
            goodsLimitConfig.isWarzoneShelfLimit == '1' ? true : false;
          this.ruleForm.goodsLimitConfig.isBuyLimit = String(
            goodsLimitConfig.isBuyLimit
          );
          this.ruleForm.goodsLimitConfig.limitCount = String(
            goodsLimitConfig.limitCount
          );
          this.ruleForm.goodsLimitConfig.shelfLimitCount = String(
            goodsLimitConfig.shelfLimitCount
          );
        }
      });
    },
    backToManage() {
      this.$router.push({
        name: 'warProductmanage',
      });
    },
    queryGoodsTypeList() {
      let data = {
        size: 99,
        current: 1,
        condition: {},
      };
      queryGoodsTypeList(data).then((res) => {
        this.tagTypeform.tagTypeCodes = [];
        res.records.forEach((item, i) => {
          let data = {
            id: item.uuid,
            label: item.tagName,
          };
          this.tagTypeform.tagTypeCodes.push(data);
          // this.tagTypeform.tagTypeCodes.push(item.tagName);
        });
      });
    },
  },
};
</script>

<style lang="scss" scoped>
.form-item-inline {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  align-items: center;
}
</style>
<style>
.el-upload,
.el-upload-list__item-delete,
.el-icon-delete {
  display: none;
}

.input_edit {
  /*position: relative;*/
  font-size: 14px;
  /*display: inline-block;*/
  width: 300px;
}

.label_edit {
  margin-left: 50px;
}

.title {
  display: block;
  margin-left: 2%;
  margin-bottom: 2%;
  font-size: 17px;
  color: #666 !important;
}

.adminSet {
  border: 1px solid #ebeef5;
  margin-left: 5px;
  padding: 31px 0px 20px 16px;
  width: 85%;
}

.el-item:hover .el-icon-error {
  visibility: inherit;
}

.el-items .el-icon-error {
  font-size: 22px;
  padding: 10px;
  color: red;
  cursor: pointer;
  visibility: hidden;
}

.tips {
  margin-left: 10px;
  color: red;
  font-size: 12px;
}
</style>
